var express = require('express')
var webpack = require('webpack')
var webpackDevMiddleWare = require('webpack-dev-middleware')
var webpackHotMiddleWare = require('webpack-hot-middleware')

var webpackConfig = require('./webpack.config')

const app = express()
const compiler = webpack(webpackConfig)
var port = process.env.port || 8080

app.use(webpackDevMiddleWare(compiler, {
  publicPath: '/dist/',
  stats: {
    colors: true
  }
}))

app.use(webpackHotMiddleWare(compiler))

app.use(express.static(__dirname))

app.listen(port, function () {
  console.log('project run in ' + port + ' port')
})